package com.aiyige.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.aiyige.MyApp;
import com.aiyige.R;

public class OperationModel implements Parcelable{

//    public final static String immediatePay = "immediatePay";
//
//    public final static String cancelOrder = "cancelOrder";
//
//    public final static String applyRefund = "applyRefund";


    public final static String  kImmediatePay = "immediatePay";     //立即付款
    public final static String  kCancelOrder = "cancelOrder";       //取消订单
    public final static String  kDeleteOrder = "deleteOrder";       //删除订单
    public final static String  kApplyRefund = "applyRefund";       //申请退款
    public final static String  kConfirmClassed = "confirmClassed"; //确认上课
    public final static String  kRefundDetail = "refundDetail";     //查看退款详情
//    public final static String  kAgreeRefund = "agreeRefund";       //同意退款
//    public final static String  kRejectRefund = "rejectRefund";     //驳回申请
    public final static String  kProcessRefund = "processRefund";   //处理退款申请





    private String operationKey;
    private String operationValue;

    public OperationModel(String operationKey) {
        this.operationKey = operationKey;
        this.operationValue = getValue(operationKey);
    }

    public OperationModel(String operationKey, String operationValue) {
        this.operationKey = operationKey;
        this.operationValue = operationValue;
    }

    public String getOperationKey() {
        return operationKey == null ? "" : operationKey;
    }

    public void setOperationKey(String operationKey) {
        this.operationKey = operationKey == null ? "" : operationKey;
    }

    public static String getValue(String operationKey) {
        String value = "";
        if (!TextUtils.isEmpty(operationKey)) {
            if (operationKey.equals(kImmediatePay)) {
                value =  MyApp.getAppContext().getString(R.string.pay_now);
            }
            else if (operationKey.equals(kCancelOrder)) {
                value =  MyApp.getAppContext().getString(R.string.order_cancel);
            }
            else if (operationKey.equals(kDeleteOrder)) {
                value =  MyApp.getAppContext().getString(R.string.delete_order);
            }
            else if (operationKey.equals(kApplyRefund)) {
                value =  MyApp.getAppContext().getString(R.string.apply_refund);
            }
            else if (operationKey.equals(kConfirmClassed)) {
                value =  MyApp.getAppContext().getString(R.string.confirm_classed);
            }
            else if (operationKey.equals(kRefundDetail)) {
                value =  MyApp.getAppContext().getString(R.string.refund_detail);
            }
            else if (operationKey.equals(kProcessRefund)) {
                value =  MyApp.getAppContext().getString(R.string.handle_refund_detail);
            }

        }
        return value;
    }



    public String getOperationValue() {
        return operationValue == null ? "" : operationValue;
    }

    public void setOperationValue(String operationValue) {
        this.operationValue = operationValue == null ? "" : operationValue;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.operationKey);
        dest.writeString(this.operationValue);
    }

    protected OperationModel(Parcel in) {
        this.operationKey = in.readString();
        this.operationValue = in.readString();
    }

    public static final Creator<OperationModel> CREATOR = new Creator<OperationModel>() {
        @Override
        public OperationModel createFromParcel(Parcel source) {
            return new OperationModel(source);
        }

        @Override
        public OperationModel[] newArray(int size) {
            return new OperationModel[size];
        }
    };
}
